Skip to content

Applies to

net11.0, net10.0, net47, net471, net472, net48, net481

public void Edit(Action<IEditableList<T>> editAction)

View source (opens in a new tab)

Summary: Applies several changes as one notification.

Parameters

NameTypeDescription
editActionAction> (opens in a new tab)The action to perform on the list; it runs under the list lock and must not mutate the list directly.

Remarks

An edit that changes the contents or only the order is announced once: CollectionChanged raises one reset, and Stream carries a Cleared notification followed by one BatchAdded notification with the whole new contents, so replaying the stream from any earlier copy ends equal to the list. ItemsAdded and ItemsRemoved show the net change. An edit with no net effect announces nothing. If the action throws, the changes it already made are kept and announced before the exception propagates. If the equality or hash code of an item throws while the net change is worked out, the edit is still committed and announced, with empty ItemsAdded and ItemsRemoved, and the exception propagates.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)Thrown when editAction is null.
System.InvalidOperationException (opens in a new tab)Thrown, from the action, when it mutates this list instead of the supplied editor.